<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <script src="./day.js"></script>
</head>

<body>
    <div class="app">
        现在是{{fmttime}}
        <br> 现在是{{dt | gettIme}}
    </div>
    <script>
        const vm = new Vue({
            data: {
                fmttime: dayjs(new Date().getTime()).format('YYYY年MM月DD日 HH:mm:ss'),
                dt: ''
                    // fmttime: ''
            },
            // computed: {
            //     fmttime() {
            //         return dayjs(new Date().getTime()).format('YYYY年MM月DD日 HH:mm:ss')
            //     }
            // }
            mounted() {
                let _this = this; // 声明一个变量指向Vue实例this，保证作用域一致
                this.timer = setInterval(() => {
                    _this.fmttime = dayjs(new Date().getTime()).format('YYYY年MM月DD日 HH:mm:ss'); // 修改数据date
                }, 1000)
            },
            filters: {
                gettIme(dt) {
                    dt = dayjs(new Date().getTime()).format('YYYY年MM月DD日 HH:mm:ss')
                    return dt
                }
            }
        })
        vm.$mount('.app')
    </script>
</body>

</html>